<%@ page pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Department Information</title>
<link href="./styles/layout.css" rel="stylesheet" type="text/css" />
<script src="<c:url value='/scripts/common.js'/>"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F4F4F4;
	font-size:12px;
}
 
-->

<!--  
a:link { text-decoration: none}  
a:active { text-decoration: none }  
a:visited { text-decoration: none }  
-->  
</style>
</head>

<body> 
<html:form action="deptInfoAction.html?method=list"> 
<script>
var url = window.location.href;
var indx = url.indexOf("&");

if(-1==indx){
 	var aa = "<c:out value="${saveErrors}"/>";
  
 	if("failure"==aa) alert("<fmt:message key="dept.common.delte.failure"/>");
 
	var errors = "<c:out value="${errors}"/>";
	 
	if(""!=errors)alert("<fmt:message key="${errors}"/>");
}	
</script>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
   <td height="25" class="home-table-tool-content02">
  <input class="home-inputBtn" type="button" name="Submit22" value="增加" onclick="javascript:MM_openBrWindow('deptInfoAction.html?method=selectNew','','width=330,height=300')" 
<p:notAllow pid="6211">
	disabled
</p:notAllow>
   
  />
     <input class="home-inputBtn" type="button" name="Submit222" value="删除" onclick="javascript:submitData('delete')" 
     <p:notAllow pid="6213">
		disabled
	 </p:notAllow>
     /> 
   </td>
 </tr>
 
 <tr>
	<td height="30" class="home-search-space">
     部门代码:&nbsp;<html:text property="code" styleId="code" styleClass="home-table-inputbox" size="12"/>&nbsp;&nbsp;&nbsp;&nbsp;
	 部门名称:&nbsp;<html:text property="name" styleId="name" styleClass="home-table-inputbox" size="12"/> &nbsp;&nbsp;&nbsp;&nbsp;
		<input name="Submit2" type="button" class="home-inputBtn" value="查询" onClick="javascript:Search();"/>
	</td>
   </tr>  

   <tr> 
    <td valign="top"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="home-table-topline"> </td>
        </tr>
        <tr> 
          <td class="home-table-leftline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-tool-content02"><sasis:page items="${deptList}"/></td>
              </tr>
              <tr> 
                <td align="center" valign="top" class="home-edittable-space">	
		<table width="100%" border="0" cellpadding="2" cellspacing="0" class="list_bordercolor">
                    
                    <tr>
                    <td width="6%" class="home-list-title">
                      &nbsp;<input name="checkbox22" type="checkbox" value="checkbox" onclick='checkAll(this.checked);' />
                    </td>
                    <td class="home-list-title">部门ID</td>
                    <td class="home-list-title">部门代码</td>
                    <td class="home-list-title">部门名称</td>
                    <td class="home-list-title">上级部门</td>
                    <p:allow pid="6212">
                    <td width="50" class="home-list-title">更新</td>
                    </p:allow>
                  </tr>
                    <c:forEach var="results" items="${deptList}" varStatus="status">
                  	<tr>
                  	
                  		<td class="home-list-content" height="26" > 
                  			&nbsp;<input type="checkbox" name="checkBoxId"  value='<c:out value="${results.id}"/>'/> 
                  		</td>
                  		<td class="home-list-content" height="26" > 
                  			&nbsp;<c:out value="${results.id}"/>
                  		</td>
                  		<td class="home-list-content" height="26" > 
                  			&nbsp;<c:out value="${results.code}"/> 
                  		</td>
                  		<td class="home-list-content"  >
                  			&nbsp;
                  			<c:if test = "${null!=results.parentName}">
                  				<c:out value="${results.name}"/><!--c:out value="${results.parentName}"/-->
                  			</c:if>
                  			<c:if test = "${null==results.parentName}">
                  				<c:out value="${results.name}"/>
                  			</c:if>		                    			
                  		</td>
                  		<td class="home-list-content"  >
                  			&nbsp;<c:out value="${results.parentName}"/>
                  		</td>
                  		<%--td class="list_font_area"  >
                  			<img src="./images/view.gif" width="14" height="14"  
				 			onclick="javascript:viewSubmit('selectOne',<c:out value="${status.count}"/>)"
						alt="<fmt:message key="provisionForm.view" />" style="cursor:hand">
					</td--%>
					<p:allow pid="6212">
                  	<td class="home-list-content"> 
                  	<img src="./images/edit.gif" width="14" height="14" style="cursor:hand" alt="<fmt:message key="common.button.update" />"
						onclick="javascript:editData('selectOne',<c:out value="${status.count}"/>)"/>
				
					</td>
				</p:allow>	
                  	</tr>	
                  </c:forEach>   
                  </table>
                  
                </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="12"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-bottom-left">&nbsp;</td>
                <td class="home-table-bottom-bg">&nbsp;</td>
                <td class="home-table-bottom-right">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="10">&nbsp;</td>
  </tr>
</table>
<input type="hidden" name="aryId"/> 
<input type="hidden" name="method"/> 
<input type="hidden" name="message" value="<bean:message key="errors.func.select"/>"/>
<input type="hidden" name="view"/>
</html:form>
</body>

<script>
//var isFlash='<c:out value="${param.method}"/>'
var isFlash='<c:out value="${reFlash}"/>';
if(isFlash!=''){
  parent.mainFrame.location.reload();
}
 function submitData(method){
		var chk = document.forms[0].checkBoxId;
		var len = chk.length;
		var ary = new Array();
	    //alert(len);
		//document.forms[0].method.value=method;
		if(len>0){
		
		for(var i=0;i<len;i++){
			if(chk[i].checked){
				ary.push(chk[i].value);
			}
		}
		
		if('delete' ==  method){
			if(ary.length>0){
				if(confirm("确定要删除该记录吗?")){ 
				}else return;	 
			}
		} 
		var aryAy = ary; 
		if(aryAy!=0){
		document.forms[0].aryId.value = aryAy;
		//alert("len>0 and checked submit"+aryAy);
		document.forms[0].action="./deptInfoAction.html?method="+method;
		document.forms[0].submit();
		 //parent.mainFrame.location.reload();
		//return;
		   }
		}else{
		//alert("len<=0 one submit");
		if(chk.checked){
			if('delete' ==  method){ 
					if(confirm("确定要删除该记录吗?")){ 
					}else return;	  
			}
		document.forms[0].aryId.value = chk.value;
		document.forms[0].action="./deptInfoAction.html?method="+method;
		document.forms[0].submit();
		// parent.mainFrame.location.reload();
		//return;
		}
	}   //alert("ary"+ary.length);
	    if(ary.length==0)
		{alert("请选择要删除的记录！");}
 
}
	
function newSubmit(method){ 
	    //document.forms[0].method.value=method;
	    document.forms[0].action="./deptInfoAction.html?method="+method;
	    document.forms[0].submit();
     }
     
     function viewSubmit(method,indx){ 
    	// alert(document.forms[0].view.value);
        document.forms[0].view.value = "view";
	    
//	    alert(indx)
	    var chk = document.forms[0].checkBoxId;
	    if(chk.length>1){
	    	document.forms[0].aryId.value = chk[indx-1].value
	    }else document.forms[0].aryId.value = chk.value
	   // document.forms[0].method.value=method;
	    
		MM_openBrWindow('deptInfoAction.html?aryId='+document.forms[0].aryId.value
		+'&view='+document.forms[0].view.value+'&method='+method,'','width=400,height=200')
	    
     	//document.forms[0].submit();
//	    submitData(method,indx)
     }
     
       function editData(method,indx){  
	    var chk = document.forms[0].checkBoxId;
	    if(chk.length>1){
	    	document.forms[0].aryId.value = chk[indx-1].value
	    }else document.forms[0].aryId.value = chk.value
	   // document.forms[0].method.value=method;
	    MM_openBrWindow('deptInfoAction.html?aryId='+document.forms[0].aryId.value
		+'&method='+method,'','width=350,height=300')
     	//document.forms[0].submit(); 
     }
     
function checkAll(status){
               //alert(status);
               for (var i=0;i < document.forms[0].elements.length; i++){
				var e = document.forms[0].elements[i];
				//alert(e.name);
				if (e.name=="checkBoxId")
					document.forms[0].elements[i].checked=status;
			}
			
		}
		
		
 
 
function shSearch(eltName){
	 
	var elt = document.getElementById(eltName);

	if(elt.style.display=="none"){ 
		elt.style.display = "";
	}else elt.style.display = "none";

} 
function Search(){
    //alert("come search");
    //将需要验证的ID传入数组
	var propertyArray = new Array();
	propertyArray.push("code");
	propertyArray.push("name");

	//alert(propertyArray.length)
	//把验证数组传入验证特殊字符函数
	var result=checkSpecialInput(propertyArray);
	//alert("result="+result);
	if(result==true||result==null){
	     //alert(result);
	    departmentForm.action="./deptInfoAction.html?method=list";
	    departmentForm.submit();
	     
	}else{
	    alert(result);
	}
}


</script>
</html>